$(document).ready(function(){

  $("#submit").click(function(){
   
	  $('#debug').empty();
	  
	  $('#notification').css('visibility','visible');
	  
	  $.post(baseurl+'user',$('#loginform').serialize(), function(data){
		  if(data =="Welcome Message")
		  {
			  var usernamevar = $('#username').val();
			  $('#debug').append("Welcome "+usernamevar+" you are login");
			  $('#close-reveal-modal').css('visibility','hidden');
			  $('#myModal').reveal({
				     animation: 'fadeAndPop',                   //fade, fadeAndPop, none
				     animationspeed: 300,                       //how fast animtions are
				     closeonbackgroundclick: false,              //if you click background will modal close?
				     dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
			  });
			  
			  
			  setTimeout(function() {
				  $("#close-reveal-modal").trigger("click");
				  $('#notification').css('visibility','hidden');
				  window.location.href = baseurl+"main/home";
				}, 2000);

		  }
		  else
		  {
			  $('#debug').append(data);
			  $('#myModal').reveal({
				     animation: 'fadeAndPop',                   //fade, fadeAndPop, none
				     animationspeed: 300,                       //how fast animtions are
				     closeonbackgroundclick: false,              //if you click background will modal close?
				     dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
			  });
			  $("#close-reveal-modal").click(function(){
				  $('#notification').css('visibility','hidden');
			  });
		  }
		  
	  });

  return false;

  });

});